import request from 'axios'
window._cancel = [];
// 获取CancelToken
request.interceptors.request.use((config) => {
    config.cancelToken = new request.CancelToken(cancel => {
        window._cancel.push({ cancel })
    })
    // 在发送请求之前做些什么，例如加入token
    // config.headers['Authorization'] = "ASJID231";
    return config;

}, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
});
// 中间 地图
export function getMap(query) {
    let url;
    query.isQuxian ? url = `http://datavmap-public.oss-cn-hangzhou.aliyuncs.com/areas/bound/${query.code}.json` : url = `http://datavmap-public.oss-cn-hangzhou.aliyuncs.com/areas/children/${query.code}.json`;
    return request({
        url,
        method: 'get',
        params: query
    })
}
// 左上 监督单位
export function getJianGuanDanWei(query) {
    return request({
        url: '/api/manageWat/statistics/unitStatisticsTotal',
        method: 'get',
        params: query
    })
}
// 左中 分专业监督户次数
export function getJianduhucishu(query) {
    return request({
        url: '/api/manageWat/statistics/speSupervisionTotal',
        method: 'get',
        params: query
    })
}
// 左下 分地区覆盖率 
export function getFuGaiLv(query) {
    return request({
        url: '/api/manageWat/statistics/supervisionAreaRate',
        method: "get",
        params: query
    })
}

// 右上 案件数
export function getAnJianShu(query) {
    return request({
        url: '/api/manageWat/statistics/penaltyBasicByYear',
        method: "get",
        params: query
    })
}

// 右下 处罚总额
// 分地区 分专业
export function getChuFaZongE(query) {
    return request({
        url: '/api/manageWat/statistics/penaltyTotalByYear',
        method: "get",
        params: query
    })
}


// 左下 监督记录统计 
export function getJianDuJiLu(query) {
    return request({
        url: '/api/manageWat/statistics/supervisionWorkTotal',
        method: "get",
        params: query
    })
}

// 左下 最新监督记录
export function getZuiXinJianDu(query) {
    return request({
        url: '/api/manageWat/statistics/supervisionWorkRecord',
        method: "get",
        params: query
    })
}

// 中 区县监督数据
export function getQuXianJianDuShu(query) {
    return request({
        url: '/api/manageWat/supervision/getMonitoringData',
        method: "get",
        params: query
    })
}

// 右 区县双随机
export function getQuXianShuangSuiJi(query) {
    return request({
        url: '/api/manageWat/supervision/getRandomYear',
        method: "get",
        params: query
    })
}
